//
//  GlobalDataTool.m
//  Project_IOS
//
//  Created by topnet on 2022/4/15.
//

#import "GlobalDataTool.h"

@implementation GlobalDataTool
static GlobalDataTool * _instance;
static dispatch_once_t onceToken;

+(GlobalDataTool*)shareInstance {
    dispatch_once(&onceToken, ^{
        if(_instance == nil) {
            _instance = [[GlobalDataTool alloc]init];
        }
    });
    return _instance;
}


- (void)checkNetwork {
//    AFNetworkReachabilityManager * manager = [AFNetworkReachabilityManager sharedManager];
//    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
//           /*
//            AFNetworkReachabilityStatusUnknown          = -1,
//            AFNetworkReachabilityStatusNotReachable     = 0,
//            AFNetworkReachabilityStatusReachableViaWWAN = 1,
//            AFNetworkReachabilityStatusReachableViaWiFi = 2,
//            */
//           switch (status) {
//               case AFNetworkReachabilityStatusUnknown:
//                   [self alert:@"网络连接异常" msg:@"请连接网络，这样才能正常使用应用所有功能"];
//                   break;
//                case AFNetworkReachabilityStatusNotReachable:
//                   [self alert:@"未检测到网络" msg:@"请连接网络，这样才能正常使用应用所有功能"];
//                   break;
//               case  AFNetworkReachabilityStatusReachableViaWWAN:
//                   NSLog(@"3G|4G蜂窝移动网络");
//                   break;
//               case AFNetworkReachabilityStatusReachableViaWiFi:
//                   NSLog(@"WIFI网络");
//                   break;
//               default:
//                   break;
//           }
//       }];
    
//    [manager startMonitoring];
}

- (void)alert:(NSString *)title msg:(NSString *)msg {
//    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
//
//    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//
//    NSLog(@"点击取消");
//
//    }]];
//
//    [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        //跳转到“About”(关于本机)页面
//        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
//        if ([[UIApplication sharedApplication] canOpenURL:url])
//        {
//            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
//
//            }];
//        }else{
//            NSLog(@"can not open");
//        }
//
//
//    }]];

    // 由于它是一个控制器 直接modal出来就好了

//    [UIApplication.sharedApplication.currentVC presentViewController:alertController animated:YES completion:nil];
}

@end
